<?php

class NameInfo
{
    private $defaultName;
    private $namePath;
    private $current_path;
    private $current_data;
    private $catch_arr_name;
    public $nameValue;
    function clname($str){
        preg_match("/(.*)\(\?(.*)~(.*)\)/",$str,$nn);
        $name=$nn[1];
        $this->defaultName=$nn[2];
        $this->namePath=$nn[3];
        $this->catch_arr_name=$name;
        return $name;
    }

    function getData($data,$path,$index=null){
        if($index==null&&$index!==0&&$index!==""){
            $this->current_path=$path;
            $result=eval("return \$data{$path};");
        }else{
            $this->current_path=$path."[$index]";
            $result=eval("return \$data{$path}[$index];");
            $this->nameValue=eval("return \$data{$path}[$index][\"{$this->namePath}\"];");
        }

        $this->current_data=$result;
        return $result;
    }
}